version 16
set more off

***********************************************************************************************************************
* THIS ROUTINE GENERATES FIGURE A.VI OF WASEEM (2020) ROLE OF WITHHOLDING ...
***********************************************************************************************************************

/* ENTRY */

use					"$project_data\STPAK_1996_2011_UBP_v1.dta", clear
keep              if business_sts=="1" 
bys					regno:egen entry=min(taxperiod)
keep					regno entry taxperiod fy item_cd business_sts tot_sale tot_purch 
g						ind=real(substr(item_cd,1,4))
drop					if ind<1600
drop					if ind>=2500 & ind<2800
bys					regno:egen sigmasales=sum(tot_sale)
bys					regno:egen sigmapurchs=sum(tot_purch)
g						va=((sigmasales-sigmapurchs)/sigmasales)*100
g 						period=mofd(entry)
qui					sum period
replace				period=period-r(min)+1
duplicates 			drop regno, force
bys					period:egen med_va=median(va)
bys					period:g index=_n
#d;
twoway  				(line  med_va period if period >24 & period<=108 & index==1,sort lwidth(thick) lcolor(red) mcolor(red) msymbol(O)),
						xtitle("Entry Period") xscale(titlegap(*10))
						xlabel(25 "1998" 37 "1999" 49 "2000" 61 "2001" 73 "2002" 85 "2003" 97 "2004" 109 "2005")
						xline(37 49, lpatter(dash) lcolor(green)) ytitle(Median Value-Addition (%), alignment(bottom)) 
						ylabel(0(25)125)  yscale(titlegap(*10))
						graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white); 	
graph 				export "$project_output\Midian_VA_By_Entry.eps", replace;
#d						cr